package com.htx.oldbookpavilion.web.mycenter;


import com.htx.oldbookpavilion.common.StandardResponse;
import com.htx.oldbookpavilion.entity.UserInfo;
import com.htx.oldbookpavilion.service.authorityservice.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/manager")
public class EditUserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    /**
     * 修改个人信息
     * @param userInfo
     * @return
     */
    @RequestMapping("/updateUserInfo")
    public StandardResponse updateUserInfo(@RequestBody UserInfo userInfo){
        StandardResponse<UserInfo> sResponse = new StandardResponse<>();
        UserInfo rUserInfo = userInfoService.updateUserInfo(userInfo);
        if (rUserInfo != null){
            sResponse.setSuccess(true);
            sResponse.setMsg("更新成功");
            sResponse.setData(userInfo);
        }else{
            sResponse.setSuccess(false);
            sResponse.setMsg("更新失败");
            sResponse.setData(null);
        }
        return sResponse;
    }
}
